using System;
using System.Runtime.InteropServices;

namespace Leap
{
	public class Tool : Pointable
	{
		private HandleRef swigCPtr;

		public new static Tool Invalid => new Tool(LeapPINVOKE.Tool_Invalid_get(), false);

		public Tool(IntPtr cPtr, bool cMemoryOwn)
			: base(LeapPINVOKE.Tool_SWIGUpcast(cPtr), cMemoryOwn)
		{
			swigCPtr = new HandleRef(this, cPtr);
		}

		public static HandleRef getCPtr(Tool obj)
		{
			return obj?.swigCPtr ?? new HandleRef(null, IntPtr.Zero);
		}

		~Tool()
		{
			Dispose();
		}

		public override void Dispose()
		{
			lock (this)
			{
				if (swigCPtr.Handle != IntPtr.Zero)
				{
					if (base.swigCMemOwn)
					{
						base.swigCMemOwn = false;
						LeapPINVOKE.delete_Tool(swigCPtr);
					}
					swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
				base.Dispose();
			}
		}

		public Tool()
			: this(LeapPINVOKE.new_Tool__SWIG_0(), true)
		{
		}

		public Tool(Pointable arg0)
			: this(LeapPINVOKE.new_Tool__SWIG_1(Pointable.getCPtr(arg0)), true)
		{
			if (!LeapPINVOKE.SWIGPendingException.Pending)
			{
				return;
			}
			throw LeapPINVOKE.SWIGPendingException.Retrieve();
		}

		public override string ToString()
		{
			return LeapPINVOKE.Tool_ToString(swigCPtr);
		}
	}
}
